package com.vast.admin.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.vast.admin.mapper.TempleteRecordSignatureMapper;
import com.vast.admin.entity.TempleteRecordSignature;
import org.springframework.util.StringUtils;

@Service
public class TempleteRecordSignatureService extends ServiceImpl<TempleteRecordSignatureMapper, TempleteRecordSignature> {

    /**
     * 获取签章坐标
     * @param templeteRecordId
     * @param type 1企业 2客户
     * @return
     */
    public List<TempleteRecordSignature> getTempleteRecordSignatures(Long templeteRecordId, Integer type, String partName) {
        QueryWrapper<TempleteRecordSignature> templeteRecordSignatureQueryWrapper = new QueryWrapper<>();
        templeteRecordSignatureQueryWrapper.eq(TempleteRecordSignature.COL_TEMPLETE_RECORD_ID, templeteRecordId)
                .eq(TempleteRecordSignature.COL_TYPE, type);
        if (StringUtils.hasText(partName)) {
            templeteRecordSignatureQueryWrapper.eq(TempleteRecordSignature.COL_PART_NAME, partName);
        }
        return super.list(templeteRecordSignatureQueryWrapper);
    }

    public List<TempleteRecordSignature> getByTempleteRecordId(Long templeteRecordId) {
        QueryWrapper<TempleteRecordSignature> templeteRecordSignatureQueryWrapper = new QueryWrapper<>();
        templeteRecordSignatureQueryWrapper.eq(TempleteRecordSignature.COL_TEMPLETE_RECORD_ID, templeteRecordId);
        return super.list(templeteRecordSignatureQueryWrapper);
    }

}
